package com.learn.container_interface.beans.service;

import com.learn.container_interface.beans.dao.UserDao;
import com.learn.container_interface.beans.dao.UserDaoImpl;

public class UserServiceImpl implements UserService {
    // 代码层面决定UserDao实现类，若需要修改实现类则要动代码。代码高耦合，不满足开闭原则
    private UserDao userDao = new UserDaoImpl();
    
    // 🌟🌟🌟
    // IOC：setUserDao方法的形参由外部传递，Spring将外部控制Bean的实现类
    // DI：UserService依赖于UserDao，Spring将存在依赖关系的Bean进行绑定
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
        System.out.println("setUserDao：" + userDao);
    }
}
